From 2523a8eb32af5fecbd70dd31dd1467bec1727b20 Mon Sep 17 00:00:00 2001 From: robertl Date: Wed, 14 Feb 2007 14:25:36 +0000 Subject: [PATCH] Change max internal resolution from centiseconds to microseconds. --- defs.h | 5 ++++- garmin.c | 2 +- gdb.c | 6 +++--- magproto.c | 4 ++-- mapsend.c | 4 ++-- mapsource.c | 2 +- nmea.c | 12 ++++++------ psitrex.c | 1 - stmsdf.c | 8 ++++---- stmwpp.c | 10 ++++++---- tef_xml.c | 9 ++++----- vitosmt.c | 4 ++-- wbt-200.c | 1 - 13 files changed, 35 insertions(+), 33 deletions(-) diff --git a/defs.h b/defs.h index ab2024f95..b7f9bb836 100644 --- a/defs.h +++ b/defs.h @@ -163,6 +163,9 @@ extern const char gpsbabel_version[]; extern time_t gpsbabel_now; /* gpsbabel startup-time; initialized in main.c with time() */ extern time_t gpsbabel_time; /* gpsbabel startup-time; initialized in main.c with current_time(), ! ZERO within testo ! */ +#define CENTI_TO_MICRO(t) (t * 10000) /* Centiseconds to Microseconds */ +#define MICRO_TO_CENTI(t) (t / 10000) /* Centiseconds to Microseconds */ + /* Short or Long XML Times */ #define XML_SHORT_TIME 1 #define XML_LONG_TIME 2 @@ -326,7 +329,7 @@ typedef struct { wp_flags wpt_flags; const char *icon_descr; time_t creation_time; /* standardized in UTC/GMT */ - int centiseconds; /* Optional hundredths of a second. */ + int microseconds; /* Optional millionths of a second. */ /* * route priority is for use by the simplify filter. If we have diff --git a/garmin.c b/garmin.c index 96b1ac15a..f43b5a18f 100644 --- a/garmin.c +++ b/garmin.c @@ -446,7 +446,7 @@ pvt2wpt(GPS_PPvt_Data pvt, waypoint *wpt) - pvt->leap_scnds; wptimes = floor(wptime); wpt->creation_time = wptimes; - wpt->centiseconds = 100.0 * (wptime - wptimes); + wpt->microseconds = 1000000.0 * (wptime - wptimes); /* * The Garmin spec fifteen different models that use a different diff --git a/gdb.c b/gdb.c index a389f07cc..2231f6665 100644 --- a/gdb.c +++ b/gdb.c @@ -90,8 +90,8 @@ /* %%% local vars %%% */ -/* static char gdb_release[] = "$Revision: 1.46 $"; */ -static char gdb_release_date[] = "$Date: 2007/02/06 23:24:14 $"; +/* static char gdb_release[] = "$Revision: 1.47 $"; */ +static char gdb_release_date[] = "$Date: 2007/02/14 14:25:36 $"; static FILE *fin, *fout; static char *fin_name, *fout_name; @@ -890,7 +890,7 @@ gdb_read_track(const size_t max_file_pos) wpt->latitude = GPS_Math_Semi_To_Deg(xlat); wpt->longitude = GPS_Math_Semi_To_Deg(xlon); wpt->creation_time = xtime; - wpt->centiseconds = 0; + wpt->microseconds = 0; wpt->altitude = xalt; wpt->depth = xdepth; diff --git a/magproto.c b/magproto.c index 5b45796ee..44c704888 100644 --- a/magproto.c +++ b/magproto.c @@ -923,7 +923,7 @@ mag_trkparse(char *trkmsg) tm.tm_mday = dmy % 100; waypt->creation_time = mkgmtime(&tm); - waypt->centiseconds = fracsecs; + waypt->microseconds = CENTI_TO_MICRO(fracsecs); if (latdir == 'S') latdeg = -latdeg; waypt->latitude = ddmm2degrees(latdeg); @@ -1319,7 +1319,7 @@ void mag_track_disp(const waypoint *waypointp) tm->tm_sec; date = tm->tm_mday * 10000 + tm->tm_mon * 100 + tm->tm_year; - fracsec = waypointp->centiseconds; + fracsec = MICRO_TO_CENTI(waypointp->microseconds); } } if (!tm) { diff --git a/mapsend.c b/mapsend.c index b0133a7cc..c04c9ab50 100644 --- a/mapsend.c +++ b/mapsend.c @@ -214,7 +214,7 @@ mapsend_track_read(void) } else { centisecs = 0; } - wpt_tmp->centiseconds = centisecs; + wpt_tmp->microseconds = CENTI_TO_MICRO(centisecs); track_add_wpt(track_head, wpt_tmp); } @@ -488,7 +488,7 @@ void mapsend_track_disp(const waypoint * wpt) /* 0 centiseconds */ if (trk_version >= 30) { - c = wpt->centiseconds; + c = MICRO_TO_CENTI(wpt->microseconds); gbfwrite(&c, 1, 1, mapsend_file_out); } } diff --git a/mapsource.c b/mapsource.c index 01e486426..edc5afd69 100644 --- a/mapsource.c +++ b/mapsource.c @@ -1582,7 +1582,7 @@ mps_track_r(FILE *mps_file, int mps_ver, route_head **trk) thisWaypoint->latitude = GPS_Math_Semi_To_Deg(lat); thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon); thisWaypoint->creation_time = le_read32(&dateTime); - thisWaypoint->centiseconds = 0; + thisWaypoint->microseconds = 0; thisWaypoint->altitude = mps_altitude; thisWaypoint->depth = mps_depth; track_add_wpt(track_head, thisWaypoint); diff --git a/nmea.c b/nmea.c index 4f757e34c..357b2760b 100644 --- a/nmea.c +++ b/nmea.c @@ -292,18 +292,18 @@ nmea_set_waypoint_time(waypoint *wpt, struct tm *time) if (time->tm_year == 0) { wpt->creation_time = ((((time_t)time->tm_hour * 60) + time->tm_min) * 60) + time->tm_sec; - if (wpt->centiseconds == 0) + if (wpt->microseconds == 0) { - wpt->centiseconds++; + wpt->microseconds++; without_date++; } } else { wpt->creation_time = mkgmtime(time); - if (wpt->centiseconds != 0) + if (wpt->microseconds != 0) { - wpt->centiseconds = 0; + wpt->microseconds = 0; without_date--; } } @@ -676,11 +676,11 @@ nmea_fix_timestamps(route_head *track) { waypoint *wpt = (waypoint *)elem; - if (wpt->centiseconds != 0) + if (wpt->microseconds != 0) { time_t dt; - wpt->centiseconds = 0; /* reset flag */ + wpt->microseconds = 0; /* reset flag */ dt = (prev / SECONDS_PER_DAY) * SECONDS_PER_DAY; wpt->creation_time += dt; diff --git a/psitrex.c b/psitrex.c index e2aa4fb17..739fec4c9 100755 --- a/psitrex.c +++ b/psitrex.c @@ -597,7 +597,6 @@ psit_track_r(gbfile *psit_file, route_head **trk) } thisWaypoint->creation_time = dateTime; - thisWaypoint->centiseconds = 0; track_add_wpt(track_head, thisWaypoint); if (gbfeof(psit_file)) break; diff --git a/stmsdf.c b/stmsdf.c index bc2e861e5..af4a68062 100644 --- a/stmsdf.c +++ b/stmsdf.c @@ -192,7 +192,7 @@ finalize_tracks(void) for (index = 0; index < count; index++) { waypoint *wpt = list[index]; - if (wpt->centiseconds == 2) { /* log continued */ + if (wpt->microseconds == 2) { /* log continued */ track = NULL; } if (track == NULL) { @@ -209,10 +209,10 @@ finalize_tracks(void) track->rte_desc = xstrdup(rte_desc); } track_add_wpt(track, wpt); - if (wpt->centiseconds == 1) { /* log pause */ + if (wpt->microseconds == 1) { /* log pause */ track = NULL; } - wpt->centiseconds = 0; + wpt->microseconds = 0; } xfree(list); @@ -290,7 +290,7 @@ parse_point(char *line) case 10: break; case 11: - if (what == 1) wpt->centiseconds = atoi(str); /* memory point type */ + if (what == 1) wpt->microseconds = atoi(str); /* memory point type */ break; } } diff --git a/stmwpp.c b/stmwpp.c index 288b21117..f82f5e43c 100644 --- a/stmwpp.c +++ b/stmwpp.c @@ -92,6 +92,7 @@ stmwpp_data_read(void) while (c != NULL) { int new_what; + int fracsec; switch(column) { @@ -135,9 +136,10 @@ stmwpp_data_read(void) break; case 6: - sscanf(c, "%d:%d:%d.%d", &time.tm_hour, &time.tm_min, &time.tm_sec, &wpt->centiseconds); + sscanf(c, "%d:%d:%d.%d", &time.tm_hour, &time.tm_min, &time.tm_sec, &fracsec); + wpt->microseconds = CENTI_TO_MICRO(fracsec); if (what == STM_TRKPT) - wpt->centiseconds /= 10; + wpt->microseconds /= 10; break; default: @@ -247,10 +249,10 @@ stmwpp_waypt_cb(const waypoint *wpt) { case STM_WAYPT: case STM_RTEPT: - gbfprintf(fout, ".%02d", wpt->centiseconds); + gbfprintf(fout, ".%02d", MICRO_TO_CENTI(wpt->microseconds)); break; case STM_TRKPT: - gbfprintf(fout, ".%03d", wpt->centiseconds * 10); + gbfprintf(fout, ".%03d", MICRO_TO_CENTI(wpt->microseconds * 10)); break; } gbfprintf(fout, ",\r\n"); diff --git a/tef_xml.c b/tef_xml.c index 3112d5fc5..9308f2036 100644 --- a/tef_xml.c +++ b/tef_xml.c @@ -151,8 +151,8 @@ void waypoint_final() int via; if (wpt_tmp == NULL) return; - via = wpt_tmp->centiseconds; - wpt_tmp->centiseconds = 0; + via = wpt_tmp->microseconds; + wpt_tmp->microseconds = 0; if (via != 0) waypt_add(wpt_tmp); @@ -202,10 +202,9 @@ tef_item_start(const char *args, const char **attrv) const char **avp = &attrv[0]; wpt_tmp = waypt_new(); - wpt_tmp->centiseconds = 0; if ((waypoints == 1) || (waypoints == item_count)) - wpt_tmp->centiseconds++; + wpt_tmp->microseconds++; waypoints++; @@ -221,7 +220,7 @@ tef_item_start(const char *args, const char **attrv) } if ((0 == strcmp(avp[0], "ViaStation")) && (0 == strcmp(avp[1], "true"))) { - wpt_tmp->centiseconds = 1; + wpt_tmp->microseconds = 1; } avp+=2; } diff --git a/vitosmt.c b/vitosmt.c index 4a9bedf64..44404a05b 100644 --- a/vitosmt.c +++ b/vitosmt.c @@ -183,7 +183,7 @@ vitosmt_read(void) tmStruct.tm_isdst =-1; wpt_tmp->creation_time = mkgmtime(&tmStruct); - wpt_tmp->centiseconds = fmod(100*seconds+0.5,100); + wpt_tmp->microseconds = fmod(1000000*seconds+0.5,1000000); wpt_tmp->shortname =xcalloc(16,1); snprintf(wpt_tmp->shortname, 15 , "WP%04d", ++serial); @@ -274,7 +274,7 @@ vitosmt_waypt_pr(const waypoint *waypointp) position += sizeof(double); tmstructp = gmtime(&waypointp->creation_time); - seconds = (double) tmstructp->tm_sec + 0.01*waypointp->centiseconds; + seconds = (double) tmstructp->tm_sec + 0.0000001*waypointp->microseconds; workbuffer[position++] =tmstructp->tm_year-100; workbuffer[position++] =tmstructp->tm_mon+1; diff --git a/wbt-200.c b/wbt-200.c index e497c619c..66344fa74 100644 --- a/wbt-200.c +++ b/wbt-200.c @@ -392,7 +392,6 @@ static int data_chunk(struct read_state *st, const void *buf, int fmt) { wpt->longitude = lon; wpt->altitude = alt; wpt->creation_time = rtim; - wpt->centiseconds = 0; sprintf(wp_name, "WP%04d", ++st->wpn); wpt->shortname = xstrdup(wp_name); -- 2.30.2